home *** CD-ROM | disk | FTP | other *** search
/ An Invitation to the Roland World of Music / Roland - An Invitation To The Roland World Of Music.bin / vb / mm-info / vbmidi.txt next >
Text File  |  1995-04-12  |  3KB  |  53 lines

  1. PSS ID Number: Q99898
  2. Article last modified on 12-27-1994
  3. 1.00 2.00 3.00
  4. WINDOWS
  5. ---------------------------------------------------------------------
  6. The information in this article applies to:
  7. - Microsoft Visual Basic programming system for Windows,
  8.   versions 1.0, 2.0, and 3.0
  9. ---------------------------------------------------------------------
  10. SUMMARY
  11. =======
  12. This article demonstrates how to play a MIDI (.MID) file from Visual Basic
  13. using Windows version 3.1 APIs.
  14. If you have the Professional Edition of Visual Basic version 2.0 or 3.0, or
  15. if you have the Professional Toolkit for Visual Basic version 1.0, you can
  16. use the MCI control to play a MIDI file. You don't need to use the APIs
  17. MORE INFORMATION
  18. ================
  19. Step by Step to an Application that Plays an .MID file
  20. ------------------------------------------------------
  21. 1. Start Visual Basic, or if Visual Basic is already running, choose New
  22.    Project from the File menu (ALT, F, N). Form1 is created by default.
  23. 2. Add a Command Button (Command1) to Form1.
  24. 3. Add the following code to the Command1_Click event of Form1:
  25.    DIM ret as Integer
  26.    '*** The following will open the sequencer with the C:\WIN31\CANYON.MID
  27.    '*** file. Canyon is the device_id. Enter the entire statement on one,
  28.    '*** single line.
  29.    ret = mciSendString("open CANYON.MID type sequencer alias canyon",
  30.       0&, 0, 0)
  31.    '*** The wait tells the MCI command to complete before returning control
  32.    '*** to the application.
  33.    Ret = mciSendString("play canyon wait", 0&, 0, 0)
  34.    '***  Close CANYON.MID file and sequencer device
  35.    Ret = mciSendString("close canyon", 0&, 0, 0)
  36. 4. Add the following code to the general declarations section of Form1:
  37.    ' Enter the following Declare statement on one, single line:
  38.    Declare Function mciSendString Lib "mmsystem" (ByVal lpstrCommand$,
  39.       ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal hCallBack%)
  40.       As Long
  41. 5. From the Run menu, choose Start (ALT, R, S) or press F5 to run the
  42.    program.
  43. More information about sndSendString() can be found in:
  44.  - The MultiMedia Programmer's Reference on page 3-26.
  45.  - Command strings described on pages 7-23 to 7-93 and in the WIN31MWH.HLP
  46.    file shipped with the Windows 3.1 Software Development Kit (SDK).
  47. Additional reference words: 1.00 2.00 3.00
  48. KBCategory: kbui kbprg
  49. KBSubcategory: APrgWindow
  50. =============================================================================
  51. Copyright Microsoft Corporation 1994.
  52.  
  53.